# set Cmake version
cmake_minimum_required(VERSION 3.10)

# set project name
project(practice)

# set exec name
set (APP practice1)

# c++
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fPIC")

# cuda
find_package(CUDA REQUIRED)
set (CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --shared -Xcompiler -fPIC")
set (CUDA_DIR /usr/local/cuda-12.8)

# TensorRT
set (TENSORRT_INSTALL_DIR /opt/tensorrt/TensorRT-10.8.0.43)

# OpenCV
set (OPENCV_DIR /usr/local/opencv4)
set (OPENCV_INCLUDE_DIR ${OPENCV_DIR})
set (OPENCV_LIB_DIR ${OPENCV_DIR}/lib)

# Path
set (BUILD_PATH ${CMAKE_BINARY_DIR}/build)
set (SRC_PATH ${CMAKE_SOURCE_DIR}/src/cpp)
set (INC_PATH ${CMAKE_SOURCE_DIR}/include)

# lib
set (CUDA_LIBS cudart cublas cudnn)
set (TENSORRT_LIBS nvinfer nvonnxparser)
set (OPENCV_LIBS opencv_core opencv_imgproc opencv_imgcodecs opencv_highgui)

file(GLOB CXX_SRC ${SRC_PATH}/*.cpp)
file(GLOB KERNELS_SRC ${SRC_PATH}/*.cu)

# add executable
add_executable(${APP} ${CXX_SRC} ${KERNELS_SRC})

# include
target_include_directories(${APP} PRIVATE
    ${INC_PATH}
    ${CUDA_DIR}/include
    ${TENSORRT_INSTALL_DIR}/include
    ${OPENCV_INCLUDE_DIR}
)

# link
target_link_directories(${APP} PRIVATE
    ${CUDA_DIR}/lib
    ${CUDA_DIR}/lib64
    ${TENSORRT_INSTALL_DIR}/lib
    ${OPENCV_LIB_DIR}
)

target_link_libraries(${APP} PRIVATE
    ${CUDA_LIBS}
    ${OPENCV_LIBS}
    ${TENSORRT_LIBS}
)